package com.atguigu.servicebase.exception;


import com.atguigu.common_uitls.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * zz: wzh
 * time 2022 09 17 21 20
 **/
@ControllerAdvice
public class GlobalException {
    @ExceptionHandler
    @ResponseBody
    public R error(Exception e){
        e.printStackTrace();
        return R.error().message("发生异常");
    }
    @ExceptionHandler(guliException.class)
    @ResponseBody
    public R error(guliException e){
        e.printStackTrace();
        return R.error().code(e.getCode()).message(e.getMsg());
    }
}
